/*
    XTU OJ: 1404
    by: fifth_light
*/

#include <stdio.h>
#include <assert.h>

typedef struct {
    int x;
    int y;
} point;

point coord_convert(int number, int size) {
    point res;
    int start, end;
    int i;
    for (i = 0; i < size; i++) {
        if (i == 0) {
            start = 1;
            end = 1;
        } else {
            start += i;
            end += (i + 1);
        }
        if (start <= number && number <= end) {
            res.x = i - (end - number);
            res.y = end - number;
            return res;
        }
    }
    for (i--; i > 0; i--) {
        start += (i + 1);
        end += i;
        if (start <= number && number <= end) {
            res.x = size - (end - number) - 1;
            res.y = (size - i) + (end - number);
            return res;
        }
    }
    assert(0);
}

int main(void) {
    int t;
    scanf("%d", &t);
    for(int i = 0; i < t; i++) {
        int n, s, e;
        scanf("%d%d%d", &n, &s, &e);
        
        point point_start, point_end;
        point_start = coord_convert(s, n);
        point_end = coord_convert(e, n);
        // printf("s: (%d, %d), e: (%d, %d)\n", point_start.x, point_start.y, point_end.x, point_end.y);
        
        int distance_x = point_end.x - point_start.x;
        int distance_y = point_end.y - point_start.y;
        distance_x = distance_x >= 0 ? distance_x : -distance_x;
        distance_y = distance_y >= 0 ? distance_y : -distance_y;
        printf("%d\n", distance_x + distance_y);
    }
    return 0;
}
